package jianzhiOffer;

import java.util.Stack;

//剑指 Offer 06. 从尾到头打印链表
public class Num06_reversePrint {

    Stack<Integer> stack = new Stack<>();
    public int[] reversePrint(ListNode head) {
        int count = 0;
        while (head!=null){
            stack.add(head.val);
            head = head.next;
            count++;
        }
        int []data = new int[count];
        for (int i = 0; i < count; i++) {
            data[i]=stack.pop();

        }
        return data;




    }
}